#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main(int argc,const char*argv[])
{
	int p=-1;
	if((p=open(argv[1],O_WRONLY))==-1){perror("打开失败");return -1;}
	char x[128];
	while(1)
	{
		printf("请输入：");
		fgets(x,128,stdin);
		x[strlen(x)-1]=0;
		write(p,x,strlen(x));
		if(strcmp(x,"q")==0)
			break;
}
	close(p);
	return 0;
};
